package com.qingzhou.web.service.impl.convert;


import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.mybatisflex.core.query.QueryWrapper;
import com.qingzhou.system.service.ISysPostService;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Inject;

import java.util.List;

public class StringArrayConverter implements Converter<List<String>> {
    @Override
    public WriteCellData<?> convertToExcelData(List<String> value, ExcelContentProperty contentProperty,
                                               GlobalConfiguration globalConfiguration) {
        if(CollUtil.isEmpty(value)) {
            WriteCellData<Object> emptyData = new WriteCellData<>("");
            emptyData.setType(CellDataTypeEnum.STRING);
            return emptyData;
        }

        return new WriteCellData<>(CollUtil.join(value,"、"));
    }
}
